In [1]:
import pandas as pd
In [2]:
df = pd.read_csv('result.csv')
df.head()
Out[2]:
Order_ID Product Quantity Price Total Order_Date Address
0 176558 USB-C Charging Cable 2 11.95 23.90 04/19/19 08:46 917 1st St, Dallas, TX 75001
1 176559 Bose SoundSport Headphones 1 99.99 99.99 04/07/19 22:30 682 Chestnut St, Boston, MA 02215
2 176560 Google Phone 1 600.00 600.00 04/12/19 14:38 669 Spruce St, Los Angeles, CA 90001
3 176560 Wired Headphones 1 11.99 11.99 04/12/19 14:38 669 Spruce St, Los Angeles, CA 90001
4 176561 Wired Headphones 1 11.99 11.99 04/30/19 09:27 333 8th St, Los Angeles, CA 90001
In [3]:
df.info(memory_usage='deep')
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 185950 entries, 0 to 185949
Data columns (total 7 columns):
 #   Column      Non-Null Count   Dtype  
---  ------      --------------   -----  
 0   Order_ID    185950 non-null  int64  
 1   Product     185950 non-null  object 
 2   Quantity    185950 non-null  int64  
 3   Price       185950 non-null  float64
 4   Total       185950 non-null  float64
 5   Order_Date  185950 non-null  object 
 6   Address     185950 non-null  object 
dtypes: float64(2), int64(2), object(3)
memory usage: 48.0 MB
In [4]:
df['Order_Date'] = pd.to_datetime(df.Order_Date, format='%m/%d/%y %H:%M')
In [5]:
df
Out[5]:
Order_ID Product Quantity Price Total Order_Date Address
0 176558 USB-C Charging Cable 2 11.95 23.90 2019-04-19 08:46:00 917 1st St, Dallas, TX 75001
1 176559 Bose SoundSport Headphones 1 99.99 99.99 2019-04-07 22:30:00 682 Chestnut St, Boston, MA 02215
2 176560 Google Phone 1 600.00 600.00 2019-04-12 14:38:00 669 Spruce St, Los Angeles, CA 90001
3 176560 Wired Headphones 1 11.99 11.99 2019-04-12 14:38:00 669 Spruce St, Los Angeles, CA 90001
4 176561 Wired Headphones 1 11.99 11.99 2019-04-30 09:27:00 333 8th St, Los Angeles, CA 90001
... ... ... ... ... ... ... ...
185945 259353 AAA Batteries (4-pack) 3 2.99 8.97 2019-09-17 20:56:00 840 Highland St, Los Angeles, CA 90001
185946 259354 iPhone 1 700.00 700.00 2019-09-01 16:00:00 216 Dogwood St, San Francisco, CA 94016
185947 259355 iPhone 1 700.00 700.00 2019-09-23 07:39:00 220 12th St, San Francisco, CA 94016
185948 259356 34in Ultrawide Monitor 1 379.99 379.99 2019-09-19 17:30:00 511 Forest St, San Francisco, CA 94016
185949 259357 USB-C Charging Cable 1 11.95 11.95 2019-09-30 00:18:00 250 Meadow St, San Francisco, CA 94016

185950 rows × 7 columns

In [6]:
df.info(memory_usage='deep')
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 185950 entries, 0 to 185949
Data columns (total 7 columns):
 #   Column      Non-Null Count   Dtype         
---  ------      --------------   -----         
 0   Order_ID    185950 non-null  int64         
 1   Product     185950 non-null  object        
 2   Quantity    185950 non-null  int64         
 3   Price       185950 non-null  float64       
 4   Total       185950 non-null  float64       
 5   Order_Date  185950 non-null  datetime64[ns]
 6   Address     185950 non-null  object        
dtypes: datetime64[ns](1), float64(2), int64(2), object(2)
memory usage: 36.8 MB
In [7]:
df['Month'] = df.Order_Date.dt.month
In [8]:
df
Out[8]:
Order_ID Product Quantity Price Total Order_Date Address Month
0 176558 USB-C Charging Cable 2 11.95 23.90 2019-04-19 08:46:00 917 1st St, Dallas, TX 75001 4
1 176559 Bose SoundSport Headphones 1 99.99 99.99 2019-04-07 22:30:00 682 Chestnut St, Boston, MA 02215 4
2 176560 Google Phone 1 600.00 600.00 2019-04-12 14:38:00 669 Spruce St, Los Angeles, CA 90001 4
3 176560 Wired Headphones 1 11.99 11.99 2019-04-12 14:38:00 669 Spruce St, Los Angeles, CA 90001 4
4 176561 Wired Headphones 1 11.99 11.99 2019-04-30 09:27:00 333 8th St, Los Angeles, CA 90001 4
... ... ... ... ... ... ... ... ...
185945 259353 AAA Batteries (4-pack) 3 2.99 8.97 2019-09-17 20:56:00 840 Highland St, Los Angeles, CA 90001 9
185946 259354 iPhone 1 700.00 700.00 2019-09-01 16:00:00 216 Dogwood St, San Francisco, CA 94016 9
185947 259355 iPhone 1 700.00 700.00 2019-09-23 07:39:00 220 12th St, San Francisco, CA 94016 9
185948 259356 34in Ultrawide Monitor 1 379.99 379.99 2019-09-19 17:30:00 511 Forest St, San Francisco, CA 94016 9
185949 259357 USB-C Charging Cable 1 11.95 11.95 2019-09-30 00:18:00 250 Meadow St, San Francisco, CA 94016 9

185950 rows × 8 columns

In [9]:
df.to_csv('result.csv', index=False)
In [ ]: